package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Clazz;
import com.itheima.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ClazzMapper {
    /**
     * 新增班级
     * @param clazz
     */
    @Insert("insert into clazz(name, room, begin_date, end_date, master_id, subject, create_time, update_time) " +
            "values(#{name}, #{room}, #{beginDate}, #{endDate}, #{masterId}, #{subject}, #{createTime}, #{updateTime})")
    void insert(Clazz clazz);

    /**
     * 查询所有班级
     * @return
     * return List<Clazz>
     */
    @Select("select * from clazz")
    List<Clazz> selectAll();

    /**
     * 分页查询班级列表
     * @param clazzQueryParam
     * @return
     */
    Page<Clazz> list(ClazzQueryParam clazzQueryParam);
    /**
     * 删除班级
     * @param id
     */
    void deleteClazz(Integer id);
    /**
     * 根据id查询班级
     * @param id
     * @return
     */
    @Select("select * from clazz where id=#{id}")
    Clazz selectById(Integer id);

    /**
     * 修改班级
     * @param clazz
     */
    @Update("update clazz set name=#{name}, room=#{room}, begin_date=#{beginDate}, end_date=#{endDate}, master_id=#{masterId}, subject=#{subject}, update_time=#{updateTime} where id=#{id}")
    void update(Clazz clazz);
}
